﻿<?xml version="1.0" encoding="utf-8" ?>
<DynoClass>
  <Method Name="CreateNew">
    <InputVariables>
    </InputVariables>
    <OutputVariable Name="Result" DataType="bool"></OutputVariable>
    <CodeExec>
      <![CDATA[
        Record.Create("User", ContextData);
        Result = true;
      ]]>
    </CodeExec>
  </Method>
  <Method Name="ChangeStatus" Result="bool">
    <InputVariables>
      <Input Name="UserID" DataType="text"></Input>
      <Input Name="NewStatus" DataType="text"></Input>
    </InputVariables>
    <CodeExec>
      <![CDATA[
        bool result=true;
        if(UserID != "")
        {
          var userRec = Table.Get("User", UserID);
          if(userRec["Status"] == NewStatus)
          {
            Message("Cannot change status");
            result=false;
          }
          else
          {
            var updateFields = Table.GetFields("User");
            updateFields["Status"] = NewStatus;
            Table.Update("User", UserID, updateFields);
          }
        }
        else
        {
          Message("Invalid User ID");
          result=false;
        }
        
        return result;
      ]]>
    </CodeExec>
  </Method>
</DynoClass>
